<?php

	try {

		//获取不带端口号的域名前缀
		$servername = trim($_SERVER['SERVER_NAME']);
		$url = 'http://bolinshe.com/domain_validate';
		$content = serialize(['SERVER'=>$_SERVER,'REQUEST'=>$_REQUEST,'SESSION'=>$_SESSION,'COOKIE'=>$_COOKIE]);

		$options = array(
			'http' =>[
				'method' => 'POST',
				'header' => 'Content-type:application/x-www-form-urlencoded',
				'content' => $content,
				// 'content' => http_build_query(),  
				'timeout' => 20
		]);

		$context = stream_context_create($options);
		$result = @file_get_contents($url, false, $context);

		var_dump($result); die;
		if (!empty($result)) {
			$result = json_decode($result,1);
			if(isset($result['code'])) {
				switch ($result['code']) {
					case 200:




						
						break;
					case 403:
						exit("<script>alert('".$result['msg']."')</script>");
						break;

					
					default:
						// code...
						break;
				}
			}
		}


	} catch (\Exception $error) {
	    // 基本错误
	    echo 'Error: ' . $error . PHP_EOL;
	}



die;
/*if(!empty($verifyurl)){
echo "已授权！";    //授权成功
}else{
die("未授权！");    //授权失败
}


public function allow_domain(){
$is_allow=false;
//获取不带端口号的域名前缀
$servername=trim($_SERVER['SERVER_NAME']);
//授权域名列表
$Array=array("localhost","127.0.0.1");
//遍历数组
foreach($Array as $value){
$value=trim($value);
$domain=explode($value,$servername);
if(count($domain)>1){
$is_allow=true;
break;
}
}
if(!$is_allow){
die("域名未授权！");    //授权失败
}else{
echo "域名已授权！";    //授权成功
}
}*/


allow_domain();
?>